<template>
  <transition name="fade">
    <div class="notice" v-if="visible">
      <div class="item">
        <h2>关于:</h2>
        <p>这个应用可以用来追踪你选择城市的当前天气</p>
        <h2>如何使用:</h2>
        <p>
          1.点击搜索框输入你希望追踪的城市<br />
          2.在搜索结果中选中一个城市，你将获取当地最新的天气<br />
          3.点击右侧的＋号可以将追踪城市的天气情况保存在首页 <br />
        </p>
        <h2>移除城市:</h2>
        <p>
          如果你不想在首页关注某个城市,可以通过底部的按钮删<br />
          除它
        </p>
        <button @click="handleClose">关闭</button>
      </div>
    </div>
    </transition>
</template>

<script setup>
const props = defineProps({
  visible: {
    type: Boolean,
    defult: false,
  },
})

const emit = defineEmits(['close'])

const handleClose = () => {
  emit('close')
}
</script>

<style lang="scss" scoped>
.notice {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 20;
  display: flex;
  justify-content: center;

  width: 100%;
  height: 100vh;

  background-color: rgb(0, 0, 0, 0.5);

  .item {
    max-width: 768px;
    margin-top: 8rem;
    padding: 1rem;
    opacity: 1;
    background-color: white;

    align-self: flex-start;
    h2 {
      font-weight: inherit;
      font-size: inherit;
    }
    p {
      font-size: 0.75rem;
      line-height: 1.2rem;
      margin-bottom: 1.5rem;
    }
    button {
      cursor: pointer;
      color: white;

      font-size: 0.75rem;
      font-weight: inherit;
      line-height: 1rem;

      padding: 8px 1.5rem;

      background-color: rgb(0, 102, 138);
      margin-top: 1rem;

      border: none;
    }
  }
}

/* 淡入淡出过渡效果 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
